package slim3.service;

import java.util.List;

import org.slim3.datastore.Datastore;
import org.slim3.util.BeanUtil;

import slim3.meta.TweetedMeta;
import slim3.model.Tweet;
import slim3.model.Tweeted;

import com.google.appengine.api.datastore.Transaction;

public class TwitteredService {

    private TweetedMeta t = new TweetedMeta();

    public Tweeted tweeted(Tweet input) {
        Tweeted tweeted = new Tweeted();
        BeanUtil.copy(input, tweeted);
        Transaction tx = Datastore.beginTransaction();
        Datastore.put(tweeted);
        Datastore.commit(tx);
        return tweeted;
    }

    public List<Tweeted> getTweetedList() {
        return Datastore.query(t).asList();
    }

}
